package HotelSystem;

public class Hotel {
    Room[][] rooms = new Room[5][5];
    public Hotel(){
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                rooms[i][j] = new Room(i * 1000+1000 + j+1,false);
            }
        }
    }
    public void show() {
        for(int i=0;i < rooms.length;i++){
            for (int j=0;j < rooms[i].length;j++){
                System.out.print(rooms[i][j].rid+":");
                System.out.print(rooms[i][j].rfree+"   ");
            }
            System.out.println();
        }
//        for (int l = 0; l < rooms.length; l++) {
//            System.out.println(Arrays.toString(rooms[l]));
//        }
//        System.out.println();
//        输出地址
    }
    public void in(int rid){
        Room room = rooms [rid / 1000-1][rid % 1000-1];
        if (room.getrfree()==true){
            System.out.println("抱歉，请预订其它空房…");
        }else {
            room.setrfree(true);
            System.out.println("您已预订"+rid+"房间");
        }
    }
    public void out(int rid) {
        Room room = rooms[rid / 1000-1][rid % 1000-1];
        if(room.getrfree()==false){
            System.out.println("您无需退订空房"+rid);
        }else {
            room.setrfree(false);
            System.out.println("您已经成功退订"+rid+"房间,感谢您的入住，欢迎下次光临！");
        }

    }
    public void exit() {
        System.out.println("感谢您的使用，系统已退出…");
    }
}
